<template>
  <div id="abnormal">
    <div class="dashboard_title">设备异常</div>
    <div class="content">
      <div class="top">
        <div>
          <div class="text-title">设备正常率</div>
          <div class="text-value">
            {{
              deviceData.onlineNumber == 0
                ? '0%'
                : (
                    (deviceData.normalNumber / deviceData.onlineNumber) *
                    100
                  ).toFixed(0) + '%'
            }}
          </div>
        </div>
      </div>
      <div class="bottom">
        <div>
          <div>
            <div class="text-title icon_5">在线总数</div>
            <div class="text-value">{{ deviceData.normalNumber }}</div>
          </div>
        </div>
        <div class="line"></div>
        <div>
          <div>
            <div class="text-title icon_6">正常</div>
            <div class="text-value">{{ deviceData.normalNumber }}</div>
          </div>
        </div>
        <div class="line"></div>
        <div>
          <div>
            <div class="text-title icon_6">告警</div>
            <div
              v-if="deviceData.alarmNumber > 0"
              style="cursor: pointer"
              @click="jumpPage"
            >
              <div class="text-value">
                {{ deviceData.alarmNumber }}
                <RightOutlined style="color: #769db0" />
              </div>
            </div>
            <div class="text-value" v-else>{{ deviceData.alarmNumber }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import router from '@/router';
import { RightOutlined } from '@ant-design/icons-vue';

const props = defineProps({
  deviceData: {
    type: Object,
    default: {},
  },
});
const jumpPage = () => {
  router.push({
    path: 'audit/log/warnLogs',
    query: { onlineStatus: '1', handleState: '0' },
  });
};
</script>

<style lang="scss" scoped>
@import './css/index.css';

#abnormal {
  background-image: url('@/assets/images/home_icon2.png');
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}
</style>
